package com.aft.terra.modules.game.model;

import com.aft.terra.modules.game.model.base.BaseShare;
import com.jfinal.plugin.activerecord.Db;

public class Share extends BaseShare<Share> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final Share dao = new Share();
	
	public Integer queryCount(Long userId) {
		StringBuilder sql = new StringBuilder();
		sql.append("select count(*) from t_share where user_id = ? ");
		return Db.queryLong(sql.toString(), userId).intValue();
	}
	
	public Integer queryCount(Long userId,String date) {
		StringBuilder sql = new StringBuilder();
		sql.append("select count(*) from t_share where user_id = ? ");
		sql.append(" and createDate between '");
		sql.append(date);
		sql.append(" 00:00:00'");
		sql.append(" and '");
		sql.append(date);
		sql.append(" 23:59:59'");
		return Db.queryLong(sql.toString(), userId).intValue();
	}

	public Integer findByCount(String state,String startDate ,String endDate) {
		String sql = new StringBuffer()
				.append("select count(*) from t_share_user where share_user_id = ? ")
				.append("and create_date between ")
				.append(startDate)
				.append(" and ")
				.append(endDate).toString();
		
		return Db.queryLong(sql,state).intValue();
	}
}
